#include <stdio.h>
#include <math.h>


/*
 * filename : Bubblesort.c
 * function : Bubble sort
 * author : xiaozhi
 * Create : 10.26
 * Copyright : copyright (C)  2006  wise
 */


#define Len 10

// Bubble sort
void Bubblesort(int array[], int n)
{
	int flag = 1, temp = 0;
	int i, j;
	for (i = 1; i < n; i++) {
		flag = 0;
		for (j = n - 1; j >= i; j--) {
			if (array[j] < array[j-1]) {
				temp = array[j];
				array[j] = array[j-1];
				array[j-1] = temp;
				flag = 1;
			}
		}

		if (flag == 0)	return ;
	}
}

// Select sort
void selectsort(int *array, int n)
{
	int i, j, m, temp;
	for (i = 0; i < n -1; i++) {
		m = i;
		for (j = i+1; j < n; j++) {
			if (array[i] < array[m]) 
				m = j;
			if (m != i) {
				temp = array[i];
				array[i] = array[m];
				array[m] = temp;
			}
		}
	}
}


// insert sort order
void insertsort(int *array, int n)
{
	int  i, j, temp;
	for (i = 1; i < n; i++) {
		temp = array[i];
		j = i -1;
		while ((j >=0) && (temp < array[j])) {
			array[j+1] = array[j];
			j--;
		}

		array[j+1] = temp;
	}
}




void main()
{
	int array[Len];
	int i;

	// input array element
	for (i = 0; i < Len; i++) {
		scanf("%d", &array[i]);
	}

	// output array before order
	for (i = 0; i < Len; i++) {
		printf("%4d", array[i]);
	}

	putchar(0xdh);

	// Bubblesort(array, Len);
	// selectsort(array, Len);
	insertsort(array, Len);

	// after sort order, finally order.
	for (i = 0; i < Len; i++) {
		printf("%4d", array[i]);
	}

	putchar('\n');
}

